package br.edu.ufcg.dsc.psoo.mymoney.controller;

import java.util.List;

import org.hibernate.SessionFactory;

import br.edu.ufcg.dsc.psoo.mymoney.controller.exceptions.AccountNotFoundException;
import br.edu.ufcg.dsc.psoo.mymoney.controller.exceptions.GroupNotFoundException;
import br.edu.ufcg.dsc.psoo.mymoney.controller.exceptions.InvalidGroupException;
import br.edu.ufcg.dsc.psoo.mymoney.model.bean.Account;
import br.edu.ufcg.dsc.psoo.mymoney.model.bean.Group;
import br.edu.ufcg.dsc.psoo.mymoney.model.bean.Type;
/**
 * Interface do controller respons�vel pela valida��o e opera��es envolvendo grupos
 * 
 * @author leonardo
 * 
 */
public interface GroupController {

	/**
	 * Fecha sess�o do Hibernate utilizada na instancia local de AccountDAO
	 */
	public abstract void closeSession();

	/**
	 * Valida e cria novo grupo
	 * 
	 * @param group
	 * @return Group grupo criado
	 * @throws InvalidGroupException
	 * @throws AccountNotFoundException
	 */
	public abstract Group create(Group group) throws InvalidGroupException,
			AccountNotFoundException;

	/**
	 * Valida e deleta grupo
	 * 
	 * @param accountId
	 *            id da conta associada ao grupo
	 * @param id
	 *            identificador do grupo
	 * @throws InvalidGroupException
	 * @throws GroupNotFoundException
	 */
	public abstract void delete(Long accountId, Long id)
			throws InvalidGroupException, GroupNotFoundException;
	
	//TODO javadoc
	public abstract void deleteFromUser(Long userId, Long id)
	throws InvalidGroupException, GroupNotFoundException;

	/**
	 * Abre sess�o do Hibernate utilizada na instancia local de AccountDAO
	 */
	public abstract void openSession();

	/**
	 * Seta a SessionFactory criada no ApplicationManager (Mentawai)
	 * 
	 * @param sf
	 *            SessionFactory
	 */
	public abstract void setSessionFactory(SessionFactory sf);

	/**
	 * Valida e atualiza grupo
	 * 
	 * @param group
	 * @return Group grupo atualizado
	 * @throws InvalidGroupException
	 */
	public abstract Group update(Group group) throws InvalidGroupException;

	/**Retorna todos os grupos cadastrados em uma conta informada
	 * @param accountId identificador da conta
	 * @return lista de grupos
	 */
	public abstract List<Group> listAll(Long accountId);
	
	//TODO javadoc
	public abstract List<Group> listAllFromUser(Long userId);
	
	//TODO javadoc
	public List<Group> findByName(String name);
	//TODO javadoc
	public Group loadById(Long id);

}